package com.zy.gen;

import java.util.*;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/12/8 15:41
 **/
public class Test {
    public static void printCollection3(Collection<? extends Person> coll){
        //Iterator只能用Iterator<?>或Iterator<? extends Person>.why?
        Iterator<?> iterator  = coll.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
    public static void printCollection4(Collection<? super Person> coll){
        Iterator<?> iterator  = coll.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }

    public static void main(String[] args) {
//        Collection<? super Person> coll  = new ArrayList<Person>();
//        Man m1  = new Man("zs");
//        Man m2  = new Man("zs2");
//        coll.add(m1);
//        coll.add(m2);
//        printCollection4(coll);


        Collection<? extends Father> colist  = new ArrayList<Child>();
        Father c1 = new Father();
//        colist.add(c1);
//        coll2.add(m2);
//        printCollection4(colist);

    }


}
